package com.cash.app.utils

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * Add vertical spacing between RecyclerView items
 * @param spacing spacing height in pixels
 */
fun RecyclerView.addVerticalSpacing(spacing: Int) {
    addItemDecoration(object : RecyclerView.ItemDecoration() {
        override fun getItemOffsets(
            outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State
        ) {
            // Don't add spacing for the last item
            if (parent.getChildAdapterPosition(view) < state.itemCount - 1) {
                outRect.bottom = spacing
            }
        }
    })
} 